﻿namespace GSMock.Config
{
    using System.Configuration;

    public class StyleSheetsCollection : ConfigurationElementCollection
    {
        public StyleSheetElement this[int index]
        {
            get
            {
                return this.BaseGet(index) as StyleSheetElement;
            }

            set
            {
                if (this.BaseGet(index) != null)
                {
                    this.BaseRemoveAt(index);
                }
                this.BaseAdd(index, value);
            }
        }

        public StyleSheetElement this[string key]
        {
            get
            {
                return this.BaseGet(key) as StyleSheetElement;
            }
        }

        protected override ConfigurationElement CreateNewElement()
        {
            return new StyleSheetElement();
        }

        protected override object GetElementKey(ConfigurationElement element)
        {
            return ((StyleSheetElement)element).Name;
        }
    }
}
